<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>选购商品</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            background-color: #f9f9f9;
            padding: 20px;
        }
        .container {
            max-width: 1200px;
            margin: auto;
            display: flex;
            flex-wrap: wrap;
            justify-content: space-between;
        }
        .product-card {
            background: white;
            border: 1px solid #ccc;
            border-radius: 8px;
            margin: 10px;
            padding: 15px;
            width: calc(25% - 20px);
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
            transition: transform 0.2s;
        }
        .product-card:hover {
            transform: scale(1.05);
        }
        .product-image {
            width: 100%;
            height: auto;
            border-radius: 5px;
        }
        h2 {
            text-align: center;
        }
        .product-name {
            font-size: 1.2em;
            margin: 10px 0;
        }
        .product-price {
            color: #d9534f;
            font-size: 1.1em;
        }
        button {
            padding: 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            width: 100%;
        }
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>

<div class="container">
    <h2>选购商品</h2>
    <div class="product-card">
        <img src="https://via.placeholder.com/150" alt="商品A" class="product-image">
        <div class="product-name">商品A</div>
        <div class="product-price">￥100</div>
        <button onclick="addToCart('商品A', 100)">加入购物车</button>
    </div>
    <div class="product-card">
        <img src="https://via.placeholder.com/150" alt="商品B" class="product-image">
        <div class="product-name">商品B</div>
        <div class="product-price">￥50</div>
        <button onclick="addToCart('商品B', 50)">加入购物车</button>
    </div>
    <div class="product-card">
        <img src="https://via.placeholder.com/150" alt="商品C" class="product-image">
        <div class="product-name">商品C</div>
        <div class="product-price">￥250</div>
        <button onclick="addToCart('商品C', 250)">加入购物车</button>
    </div>
    <div class="product-card">
        <img src="https://via.placeholder.com/150" alt="商品D" class="product-image">
        <div class="product-name">商品D</div>
        <div class="product-price">￥80</div>
        <button onclick="addToCart('商品D', 80)">加入购物车</button>
    </div>
</div>

<script>
    function addToCart(productName, productPrice) {
        alert(`${productName} 已加入购物车，价格为￥${productPrice}`);
        // 在这里可以添加实际的添加到购物车逻辑
    }
</script>

</body>
</html>
